﻿using MaterialManagement.API.Application.Command.ERP;
using MaterialManagement.Domain.ERP;
using MaterialManagement.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MaterialManagement.API.Controllers
{
    /// <summary>
    /// 物料库存控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MaterialController : ControllerBase
    {
        private readonly IMediator mediator;

        public MaterialController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取物料信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<MaterialInfoModel>>> GetMaterialInfo([FromQuery]GetMaterialInfoCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 通过编号获取物料信息接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<MaterialInfoModel>> GetIdMaterialInfo([FromQuery]GetIdMaterialInfoCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 出库记录显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<OutboundRecordModel>>> GetOutboundRecord([FromQuery]GetOutboundRecordCommand request)
        {
            return mediator.Send(request);
        }
    }
}
